package com.liam.apppush.util;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;

/**
 * Created by neo on 2016/10/26.
 */
public class MyHttpClientUtils {

        private static final int DEFAULT = 100;

        private static PoolingHttpClientConnectionManager manager = new PoolingHttpClientConnectionManager();

        private static CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(manager).build();

        static {
            manager.setMaxTotal(2 * DEFAULT);
            manager.setDefaultMaxPerRoute(DEFAULT);
        }

        public static CloseableHttpClient getHttpClient(){

            return httpClient;
        }

        public static void setMaxTotal(int num){

            manager.setMaxTotal(num);
        }

        public static void setDefaultMaxPerRoute(int num){

            manager.setDefaultMaxPerRoute(num);
        }
}
